/*
* 数据计算工具
* */
export default {

  checkPosNumber(value, c = 3) {
    let v = value.replace(/[^\d.?$\d]/g, '')
    v = v.replace("/-/g", "")
    let i = v.indexOf('.')
    if (i < 1) {
      return v
    } else {
      if (i < v.length - c) {
        return v.substr(0, i + c)
      }
      return v
    }
  },
  //数字保留两位小数
  keepTwoDecimal(num) {
    var result = parseFloat(num);
    if (isNaN(result)) {
      return false;
    }
    result = Math.round(num * 100) / 100;
    return result;
  }
}
